//
//  AppDelegate.m
//  觅尚
//
//  Created by No.8 on 2019/3/19.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "AppDelegate.h"
#import "MSAccuntLoginController.h"
#import "MSLoginController.h"
#import "MSTaBbarController.h"
#import "MSCompanyController.h"
#import "MSHomeController.h"
#import "DFZMovieView.h"
#import "MSCompanyController.h"
#import "HYNewFeatureCtr.h"
#import "DFZMovieController.h"

#define STORE_APPID @"1458685882"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
    manager.enable = YES;
    manager.shouldResignOnTouchOutside = YES;
    manager.shouldToolbarUsesTextFieldTintColor = YES;
    manager.enableAutoToolbar = NO;
    
    [NSThread sleepForTimeInterval:0.5];
    self.window = [[UIWindow alloc]init];
    self.window.frame = [UIScreen mainScreen].bounds;
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    [self.window makeKeyAndVisible];
    // 是否展示新特性界面
    BOOL canShow = [HYNewFeatureCtr canShowNewFeature];
    NSString *versionCache = [[NSUserDefaults standardUserDefaults] objectForKey:@"VersionCache"];// 本地缓存的版本号  第一次启动的时候本地是没有缓存版本号的。
    WYCLog(@"------%@",versionCache);
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];// 当前应用版本号
    WYCLog(@"------%@",version);
//    if (![versionCache isEqualToString:version]) {
//        canShow = YES;
//    }
    //测试代码，正式版本应该删除
    
    if(canShow){ // 初始化新特性界面
        self.window.rootViewController = [HYNewFeatureCtr newFeatureVCWithImageNames:@[@"1",@"2",@"3",@"4"]  dotImage:@"" currentDotImage:@"" enterBlock:^{
            
            NSLog(@"进入主页面");
            
            
        } configuration:^(UIButton *enterButton) { // 配置进入按钮
            
            enterButton.bounds = CGRectMake(0, 0, 120, 33);
            enterButton.center = CGPointMake(BWScreenWidth * 0.5f, BWScreenHeight* 0.9f);
            [enterButton setBackgroundColor:FontColor];
            enterButton.layer.cornerRadius = 5 * px;
            enterButton.layer.masksToBounds = YES;
            [enterButton setTitle:@"立即体验" forState:UIControlStateNormal];
            [enterButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [enterButton addTarget:self action:@selector(enterButtonClick) forControlEvents:UIControlEventTouchUpInside];
            enterButton.titleLabel.font = [UIFont systemFontOfSize:20];
            
        }];
        
    }else{  // 主界面
        
        
//         = [[MSAccuntLoginController alloc]init];
        
//        if (![versionCache isEqualToString:version]) { // 如果本地缓存的版本号和当前应用版本号不一样，则是第一次启动（更新版本也算第一次启动）
//            DFZMovieController *movieVC = [[DFZMovieController alloc] init];
        
        self.window.rootViewController = [[DFZMovieController alloc] init];;
            
            // 设置上面这句话，将当前版本缓存到本地，下次对比一样，就不走启动视屏了。
            // 也可以将这句话放在WSMovieController.m的进入应用方法里面
            //         为了让每次都可以看到启动视屏，这句话先注释掉
            //         [[NSUserDefaults standardUserDefaults] setObject:version forKey:@"VersionCache"];
            
//        }
        
    }
    
//    / OC
   
    
   
    
//    [self Versionupdate];
    
    
    return YES;
}
- (void)enterButtonClick{
    
    MSAccuntLoginController *viewVC = [[MSAccuntLoginController alloc] init];
    self.window.rootViewController = viewVC;
    
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
